package win.larryzeal.jmx.sm;

import java.security.Permission;

/**
 * Created by 张少昆 on 2017/8/17.
 */
public class MySecurityManager extends SecurityManager {

    /**
     * Throws a <code>SecurityException</code> if the
     * calling thread is not allowed to read the file specified by the
     * string argument.
     * <p>
     * This method calls <code>checkPermission</code> with the
     * <code>FilePermission(file,"read")</code> permission.
     * <p>
     * If you override this method, then you should make a call to
     * <code>super.checkRead</code>
     * at the point the overridden method would normally throw an
     * exception.
     *
     * @param file the system-dependent file name.
     * @throws SecurityException    if the calling thread does not have
     *                              permission to access the specified file.
     * @throws NullPointerException if the <code>file</code> argument is
     *                              <code>null</code>.
     * @see #checkPermission(Permission) checkPermission
     */
    @Override
    public void checkRead(String file){
        // super.checkRead(file);
        if(file == null || file.contains("test")){
            throw new SecurityException("抱歉，我拒绝你的读取");
        }
    }
}
